package com.zlsy.springbootdemo.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.elasticsearch.index.VersionType;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.TypeAlias;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;

/**
 * @author zhouliang
 * @date 2020/05/30
 **/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TypeAlias("test")
@Document(indexName = "test", shards = 1, replicas = 0, createIndex = false, versionType = VersionType.EXTERNAL)
public class TestCreateIndexAndDate {

    @Id
    private Long id;

    @Field(name = "name", type = FieldType.Keyword)
    private String name;

    @Field(name = "age", type = FieldType.Integer)
    private Integer age;

    @Field(name = "date", type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss")
    private Date date;
}
